package com.yanqu.road.entity.activity.daomu.skillstrategy.passive.impl;

import com.yanqu.road.entity.activity.daomu.DaoMuAttribute;
import com.yanqu.road.entity.activity.daomu.config.DaoMuSkillConfig;
import com.yanqu.road.entity.activity.daomu.enums.DaoMuAttributeEnum;
import com.yanqu.road.entity.activity.daomu.enums.DaoMuDamageBuffTypeEnum;
import com.yanqu.road.entity.activity.daomu.skillstrategy.passive.ISkillPassiveStrategy;
import com.yanqu.road.entity.activity.daomu.skillstrategy.passive.req.DaoMuPassiveSkillCountAttributeReq;
import com.yanqu.road.utils.string.StringUtils;

/**
 * 尸蟞丹
 */
public class SkillZombieStrategy implements ISkillPassiveStrategy {

    /**
     * 计算属性MAP
     * @param req
     */
    @Override
    public void countAttribute(DaoMuPassiveSkillCountAttributeReq req) {
        //技能配置
        DaoMuSkillConfig daoMuSkillConfig = req.getDaoMuSkillConfig();
        String[] skillParaArr = daoMuSkillConfig.getSkillPara().split("\\|");
        //增加移动速度千分比
        long addRate = Long.parseLong(skillParaArr[22]);
        //特殊加成
        String specialParamStr = skillParaArr[23];
        if (!StringUtils.isNullOrEmpty(specialParamStr) && !specialParamStr.equals("0")) {
            String[] parmaArr = specialParamStr.split(";");
            long hpRate = Integer.parseInt(parmaArr[0]);//移动速度(触发条件(血量最大值)
            long specialAddRate = Integer.parseInt(parmaArr[1]);//增加移动速度千分比
            //判断血量是否低于配置
            if (req.getMyHpRate() < hpRate) {
                addRate += specialAddRate;
            }
        }
        //伤害减免
        DaoMuAttribute attAttribute = req.getAttributeMap().get(DaoMuAttributeEnum.ATTRIBUTE_SPEED.getType());
        attAttribute.addAddRate(addRate);
    }
}
